﻿<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<head>
<title>名师列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<%=request.getContextPath()%>/style/adminStyle.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/public.js"></script>
<script type="text/javascript">
function selec() {
	var str=${admin.jurisdiction};
	if(str==1){
		alert("权限不足");
		return false;
	}
	return true;
}
function selt() {
	var i=1;
	var emp=$("#emp").val();
	var number=$("#number").val();
	if(emp==null||emp==""){
		i=0;
	}
	if(i==1){
		if(number==2&&emp.length>9|/^[\u4E00-\u9FA5]+$/g.test(emp)){
			alert("查询条件不正确");
			 return false;
		}
		if(number==1&&emp!=11){
			alert("查询条件不正确");
			 return false;
		}
		return true;
	}else{
		alert("条件不能为空"); 
		return false;
	}
}

</script>
</head>
<body>
 <div class="wrap">
  <div class="page-title">
    <span class="modular fl"><i class="user"></i><em>名师列表</em></span>
    <span class="modular fr"><a href="../Administrators/add_category.do" class="pt-link-btn" onclick="return selec()">+添加新名师</a></span>
  </div>
  <div class="operate">
   <form action="../Administrators/master_gettiem.do">
    <select class="inline-select" name="number" id="number">
     <option value="1">名师电话</option>
     <option value="2">名师ID</option>
     <option value="3">名师昵称</option>
    </select>
    <input type="text" class="textBox length-long" placeholder="输入查询条件..." name="emp" id="emp"/>
    <input type="submit" value="查询" class="tdBtn" onclick="return selt()"/>
   </form>
  </div>
  <table class="list-style Interlaced">
   <tr>
     <th>ID</th>
      <th>类型</th>
     <th>大师头像</th>
     <th>大师昵称</th>
     <th>性别</th>
     <th>手机号码</th>
     <th>擅长领域</th>
     <th>可预约位数</th>
     <th>操作</th>
   </tr>
    <c:if test="${res!=null}">
   <tr>
    <td class="center">${res.id}</td>
     <td class="center">${res.general}</td>
     <td class="center"><img src="${res.url}" class="thumbnail"/></td>
    <td class="center">${res.iname}</td>
    <td class="center">
     <c:if test="${res.sex==0}">
    	<span>女</span>
	</c:if>
	  <c:if test="${res.sex==1}">
    	<span>男</span>
	</c:if>
    </td>
    <td class="center">${res.wechatnumber}</td>
  
    <td class="center">${res.type}</td>
    <td class="center">${res.counts}</td>
    <td class="center">
     <a href="../Administrators/master_getresID.do?id=${res.id}" class="inline-block" title="编辑" onclick="return selec()"><img src="<%=request.getContextPath()%>/images/icon_edit.gif"/></a>
   
     <a class="inline-block" title="删除" onclick="del(${res.id});"><img src="<%=request.getContextPath()%>/images/icon_drop.gif"/></a>
    </td>
   </tr>
   </c:if>
  </table>
  <!-- BatchOperation -->
  <div style="overflow:hidden;">
      <!-- Operation -->
	 <!--  <div class="BatchOperation fl">
	   <input type="checkbox" id="del"/>
	   <label for="del" class="btnStyle middle">全选</label>
	   <input type="button" value="批量删除" class="btnStyle"/>
	  </div> -->
	  <!-- turn page -->
	  <div class="turnPage center fr">
	   <a >上一页</a>
	   <a>当前：第1页,共1页</a>
	   <a >下一页</a>
	  </div>
  </div>
 </div>
 <script type="text/javascript">
 function del(id) {
		var msg = "您确定要删除吗？\n\n请确认！";
		var sr=${admin.jurisdiction};
		
		if (confirm(msg)==true){
			if(sr==1){
				  alert("权限不足");
			}else{
				$.ajax({
					"url":"${pageContext.request.contextPath}/Administrators/master_delete.do",
					"data":"id="+id,
					"type":"POST",
					"dataType":"json",
					"success":function(obj){

						if(obj.state==1){
							 alert("删除成功");
							window.location="${pageContext.request.contextPath}/Administrators/master_list.do";
							
						}else{
							 alert("删除失败");
						}
				
					}});
			}
		}
		}
 
 
 </script>
</body>
</html>